function deleteNth(arr, n) {
  let nth = []
  for (let i = 0; i < n; i++) {
    nth.push(arr[i])
  }
  for (let j = n; j < arr.length; j++) {


    nth.push(arr[j])
  }

  console.log(nth)
}

function deleteNth(arr, n) {
  if (!arr) { return null; }
  if (n < 1) { return []; }

  var nth = [];
  var itemCounts = {};
  for (var i = 0; i < arr.length; i++) {
    var item = arr[i];
    var count = itemCounts[item] || 0;
    if (count < n) {
      nth.push(item);
      itemCounts[item] = count + 1;
    }
  }
  return nth;
}

function deleteNth(arr, x) {
  var cache = {};
  return arr.filter(function (n) {
    cache[n] = (cache[n] || 0) + 1;
    return cache[n] <= x;
  });
}

const deleteNth = (a, x) => {
  let m = {};
  return a.filter(v => (m[v] = m[v] + 1 || 1) <= x);
}

function deleteNth(arr, x) {
  var count = {};
  return arr.filter(function (a) {
    count[a] = ~~count[a] + 1;
    return count[a] <= x;
  })
}//z.

function deleteNth(arr, x) {
  return arr.reduce(function (a, v) {
    return count(a, v) < x ? a.concat(v) : a;
  }, []);
}
function count(arr, z) {
  return arr.filter(function (q) { return z == q }).length;
}

function deleteNth(arr, x) {
  var obj = {}
  return arr.filter(function (number) {
    obj[number] = obj[number] ? obj[number] + 1 : 1
    return obj[number] <= x
  })
}


const deleteNth = (arr, x) => arr.filter((e, i) => arr.slice(0, i).filter(f => f == e).length < x);


function deleteNth(arr, x) {
  let h = {};
  return arr.filter((n) => (h[n] = ~~h[n] + 1) <= x);
}

function deleteNth(arr, x) {
  var res = []
  var map = {}

  for (var i = 0; i < arr.length; i++) {
    var n = arr[i]
    var c = map[n] = (map[n] || 0) + 1
    if (c <= x) res.push(n)
  }

  return res
}

const deleteNth = (arr, n) => {
  let obj = {};
  return arr.filter(num => (
    obj[num] = (obj[num] || 0) + 1,
    obj[num] <= n
  ));
}

function deleteNth(arr, x) {
  return arr.filter(
    (e, i) => arr.slice(0, i).filter(e2 => e2 == e).length < x
  );
}

function deleteNth(arr, n) {
  new_arr = []
  arr.forEach((element) => {
    if (new_arr.filter(i => i === element).length < n) {
      new_arr.push(element);
    }
  })
  return new_arr;
}

const deleteNth = (arr, n, found = {}) => arr.filter(num => (found[num] = (found[num] || 0) + 1, found[num]) <= n);

const deleteNth = (arr, n) =>
  arr.filter((val, idx) => arr.slice(0, idx).filter(v => v === val).length < n);

deleteNth([1, 1, 3, 3, 7, 2, 2, 2, 2], 3)
